package com.it.btyw.modules.station.viewmodel

import com.it.common.bean.CommonBean
import com.it.common.livedata.UnPeekLiveData
import com.it.data.base.BaseViewModel
import com.it.data.network.Api
import com.it.data.network.rsp.GQStationVo
import com.it.data.network.rsp.PageVo
import com.it.data.network.rsp.WtGQVo
import com.it.data.utils.HttpParamUtil


class GQStationViewModel : BaseViewModel() {

    val pageGQStationVoListLiveData by lazy { UnPeekLiveData<CommonBean<PageVo<List<GQStationVo>>>>() }
    val pageWtGQVoListLiveData by lazy { UnPeekLiveData<CommonBean<PageVo<List<WtGQVo>>>>() }

    /**
     *查询测站列表
     * @param userId String
     * @param pageNum Int
     * @param pageSize Int
     * @param addvcd String 行政区规划
     * @param sttp String  测站类型
     * @param projecttype String 数据来源
     * @param quedeal Int 运维状态 1 正常 0 问题
     * @param stnm String 查询条件（测站编码或者名称）
     * @return ResultBean<PageVo<List<GQStationVo>>>
     */
    fun getGQStationList(
        userId: String,
        pageNum: Int,
        pageSize: Int,
        addvcd: String? = null,
        sttp: String? = null,
        projecttype: String? = null,
        quedeal: String? = null,
        stnm: String? = null,
    ) {
        requestCommit(request = {
            val list = mutableListOf<String>()
            list.add(userId)
            list.add(pageNum.toString())
            list.add(pageSize.toString())


            var url = HttpParamUtil.buildStationListUrl(list, Api.GET_GQSTATIONLIST)
            Api.apiClient()
                .getGQStationList(
                    url,
                    addvcd = addvcd,
                    sttp = sttp,
                    projecttype = projecttype,
                    quedeal = quedeal,
                    stnm = stnm,
                )
        }, resp = {
            pageGQStationVoListLiveData.postValue(it)
        })
    }

    /**
     * 运维记录列表
     * @param pageNum Int
     * @param pageSize Int
     * @param trcd String?
     * @param stcd String
     * @param queType String?
     * @param queDeal Int?
     * @param type Int?
     */
    fun getWtGQ(
        pageNum: Int,
        pageSize: Int,
        trcd: String? = null,
        stcd: String,
        queType: String? = null,
        queDeal: String? = null,
        type: Int? = null,
    ) {
        requestCommit(request = {
            val list = mutableListOf<String>()
            list.add(pageNum.toString())
            list.add(pageSize.toString())
            var url = HttpParamUtil.buildStationListUrl(list, Api.GET_WTGQ)
            Api.apiClient()
                .getWtGQ(
                    url,
                    stcd = stcd,
                    trcd = trcd,
                    queDeal = queDeal,
                    queType = queType,
                    type = type
                )
        }, resp = {
            pageWtGQVoListLiveData.postValue(it)
        })
    }


}